package com.cykj.pos.applet.mapper.provider;

import com.cykj.common.utils.StringUtils;
import com.cykj.pos.applet.domain.ao.AppletAO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

/**
 * @author wangjiaqi
 * @date 2022/1/24
 */
public class AppletMapperProvider {

    public String getList(@Param("m") AppletAO m) {
        SQL sql = new SQL();
        sql.SELECT("user_name as userName, trans_date as transDate, trans_amount as transAmount")
                .FROM("biz_merch_transactions")
                .WHERE("pos_code = (SELECT sn FROM biz_merchant_entry WHERE phone = #{m.phone}) " +
                        "and error_msg = '交易成功' ");
        if (StringUtils.isNotEmpty(m.getStartTime()) && StringUtils.isNotEmpty(m.getEndTime())) {
            sql.WHERE("trans_date > #{m.startTime} and trans_date < #{m.endTime}");
        }
        sql.ORDER_BY("transDate desc");
        return sql.toString();
    }
}
